<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>积分商城</title>
<link type="text/css" href="__CSS__/main.css" rel="stylesheet"/>
<link type="text/css" href="__CSS__/wild.css" rel="stylesheet"/>
<script type="text/javascript" src="__PUBLIC_JS__/jquery.js?v={$src_version}" ></script>
<script type="text/javascript" src="__PUBLIC_JS__/zepto.min.js" ></script>
<script type="text/javascript" src="__PUBLIC_JS__/fastclick.js" ></script>
<script type="text/javascript" src="__PUBLIC__/layer_mobile/layer.js" ></script>   
<script type="text/javascript" src="__PUBLIC_JS__/ming.js?v={$src_version}" ></script>
<style>

</style>
</head>
<body>
<div class="reback"><img src="__IMG__/reback.svg" onclick="javascript:history.back(-1);"></div>
<div id="lightA" class="light" style="display:none;">
    <div class="top_wz">你是否确定兑换该商品？</div>
    <div style="margin-bottom: 20px" >
        数量：
        <span class="value">
            <span class="operation reduce" >-</span>
            <input type="number" name="num" value="1" id="num" min="1" readonly="readonly"/>
            <span class="operation add">+</span>
        </span>
        
    </div>
   
    <ul class="xz_li">
    	<li class="h_li"><a href="javascript:void(0)" onclick="closeDiv('A')">取消</a></li>
        <li class="b_li"><a href="javascript:;" data-gid="" id="sbt">确定</a></li>
    </ul>
</div>
<div id="fadeA" class="black_overlay"></div> 
<div class="integral-left">
    <ul>
        <volist name="sort_info" id="vo" key="j">
            <li onclick="ajax('{$vo.id}')">{$vo.sort_name}</li>
        </volist>   
    </ul>
</div>
<div class="integral-right" id="shop_war">
    <volist name="goods" id="v">
        <div class="integral-item">
            <div class="integral-img">
                <img src="/{$v.pics}">
            </div>
            <div class="integral-detail">
                <p class="title">{$v.gname}</p>
                <p><span>{$v.gpoint}</span>积分<span class="exchange right" onClick="openDiv('A',{$v.gid})">立即兑换</span></p>
            </div>
        </div>
    </volist> 

</div>
<!--弹出新增学生js-->
<script>
function openDiv(id,gid,num){
	document.getElementById('light'+id).style.display='block';
	document.getElementById('fade'+id).style.display='block';
	$('#sbt').attr('data-gid',gid);
	
	
}
function closeDiv(id){
	document.getElementById('light'+id).style.display='none';
	document.getElementById('fade'+id).style.display='none'
}

 $(function(){

     /*单击减号按钮增加*/
    $(".add").click(function(){   
        var add = $(this).siblings("input");   
        add.val(parseInt(add.val())+1)   
    });   
        
    /*单击减号按钮减少*/  
    $(".reduce").click(function(){   
        var min = $(this).siblings("input");   
        min.val(parseInt(min.val())-1)   
        if(parseInt(min.val())<1){   
            min.val(1);  
    }  
    });

     FastClick.attach(document.body);// 解决 延迟300ms 
	 
     $('#sbt').click(function(){
		 
		var gid=$(this).data('gid');
        var num=$('#num').val();
	    if(gid==''){layer.open({ content:'请选择要兑换的商品' ,skin: 'msg' ,time: 2  });return ;} 
        if(num<1){
        }else{
            $.ajax({
            type:'post',
            url:'{:U("User/handle_goods")}',
            data:{gid:gid,num:num,act:'add'},  
            dataType:'json',
            success:function(res){
                layer.open({ content:res.msg ,skin: 'msg' ,time: 2  });
                
                res.code=='1'?setTimeout("goURL('"+res.url+"')",500):'';   return ;
                //alert(res);
                }

            });
        }

	   });	   
   });

//弹出编辑
    function ajax(id)
    {
        var xmlhttp;
        if (window.XMLHttpRequest)
        {
    // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
            xmlhttp=new XMLHttpRequest();
         }
        else
        {
    // IE6, IE5 浏览器执行代码
             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
         xmlhttp.open("GET","{:U('User/sort')}?sort_id="+id,true);
         xmlhttp.send();
        xmlhttp.onreadystatechange=function()
        {
             if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {
                     var obj = xmlhttp.responseText;
                     jiexi(obj);
                }
        }
    }

    function jiexi(obj)
    {
        var shop = document.getElementById('shop_war');
        var goods = eval('('+obj+')');
        shop.innerHTML = '';
        for (var i = 0;  i < goods.length ; i++) 
        {
        shop.innerHTML='<div class="integral-item">\
                            <div class="integral-img">\
                                <img src="/'+goods[i]['pics']+'">\
                            </div>\
                            <div class="integral-detail">\
                                <p class="title">'+goods[i]["gname"]+'</p>\
                                <p><span>'+goods[i]['gpoint']+'</span>积分<span class="exchange right" onClick="openDiv(\'A\','+goods[i]['gid']+')">立即兑换</span></p>\
                            </div>\
                        </div>';
        }
    }
    $(function(){
        $('.integral-left ul li').click(function(){
            $('.integral-left ul li').css('color','#999');
            $(this).css('color','#83a500');
        })
    })

</script>

</body>
</html>